<template>
  <div class='container'>
      <el-dialog
    title="题目审核"
    :visible="showDialogChe"
    @close="closeDialog"
    top="8vh"
    >
   <div   class="flexBox">
    <el-radio v-model="dataForm.chkState" :label="1">通过</el-radio>
    <el-radio v-model="dataForm.chkState" :label="2">拒绝</el-radio>
   </div>
    <el-input v-model="dataForm.chkRemarks" type="textarea" placeholder="请输入审核意见" style="width:370" />
     <div  class="right">
    <el-button size="medium" @click="closeDialog">取消</el-button>
    <el-button type="primary" size="medium" @click="getCheck">确认</el-button>
     </div>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  data () {
    return {
      dataForm: {
        chkRemarks: '',
        chkState: 1,
        id: ''
      }
    }
  },
  props: {
    showDialogChe: {
      type: Boolean,
      default: false
    },
    dataCheckk: {
      type: Object,
      default: () => {}
    }
  },
  methods: {
    closeDialog () {
      this.$emit('update:showDialogChe', false)
      this.dataForm = {
        chkRemarks: '',
        chkState: 1,
        id: ''
      }
    },
    // 点击确认以后
    /**
     * 1:校验，确定输入审核意见
     * 2:赋值，将父组件传过来的id赋值
     * 3：发请求
     * 4：父组件重新渲染列表
     */
    async getCheck () {
      if (!this.dataForm.chkRemarks) {
        return this.$message.error('请输入审核意见')
      }
      this.dataForm.id = this.dataCheckk.id
      const { data } = await choiceCheck(this.dataForm)
      console.log(data)
      this.closeDialog()
      this.$emit('dataList')
    }
  }
}
</script>

<style scoped lang='scss'>
  ::v-deep{
    .el-dialog{
      width: 400px;
    }
  }
  .container{
    display: flex;
    align-items: center;
  }
  .right{
  margin-top: 30px;
  display: flex;
  justify-content: flex-end;

}
.flexBox{
  margin-bottom: 30px;

}
</style>
